package org.ptkparty.client;

import java.util.Set;

import org.ptkparty.client.model.ChampionshipProxy;
import org.ptkparty.client.place.PlayerDto;

public class Context {

	private static Context INSTANCE;

	public static Context get() {
		if (INSTANCE == null) {
			INSTANCE = new Context();
		}
		return INSTANCE;
	}

	private String currentChampionship;

	private Set<ChampionshipProxy> championshipList;

	private PlayerDto currentPlayer;

	public void setCurrentChampionship(String currentChampionship) {
		this.currentChampionship = currentChampionship;
	}

	public Set<ChampionshipProxy> getChampionshiplist() {
		return championshipList;
	}

	public void setChampionshipList(Set<ChampionshipProxy> championshipList) {
		this.championshipList = championshipList;
	}

	public String getCurrentChampionship() {
		return currentChampionship;
	}

	public ChampionshipProxy getCurrentChampionshipProxy() {
		for (ChampionshipProxy c : championshipList) {
			if (c.getId().equalsIgnoreCase(currentChampionship)) {
				return c;
			}
		}
		return null;
	}

	public PlayerDto getCurrentPlayer() {
		return currentPlayer;
	}

	public void setCurrentPlayer(PlayerDto currentPlayer) {
		this.currentPlayer = currentPlayer;
	}
}
